#include<iostream>

using namespace std;
long long a[1234567],n,w,k;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    a[0]=0;
    a[n+1]=0x3f3f3f3f;
    int flag=0;
    for(int i=2;i<=n;i++){
            //if(flag==0&&a[i]>a[i-1]) continue;
        if(flag==0&&a[i]<a[i-1]){
                w=i-1;
            flag=1;
        }
    //else if(flag==1&&a[i]<a[i-1]) continue;
        else if(flag==1&&a[i]>a[i-1]){
            k=i-1;
            flag=2;
        }
        else if(flag==2&&a[i]<a[i-1]){
            cout<<"impossible"<<endl;
            return 0;
        }
       // cout<<flag<<" "<<i<<endl;
    }
    if(flag==0){
        cout<<"1 1"<<endl;
        return 0;
    }
    if(flag==1){
        k=n;

    }
    while(a[w]==a[w-1]){
        w--;
    }
if(a[k]>=a[w-1]&&a[w]<=a[k+1]){
        cout<<w<<" "<<k<<endl;
        return 0;
    }

    else{
            cout<<"impossible"<<endl;
    return 0;
    }


    return 0;
}
